package com.zygh.interactiveplatform.module.controller;


import com.alibaba.fastjson.JSONObject;
import com.zygh.interactiveplatform.common.anno.PcLog;
import com.zygh.interactiveplatform.common.constant.SwaggerTagConst;
import com.zygh.interactiveplatform.common.domain.ResponseDTO;
import com.zygh.interactiveplatform.module.entity.Autologos;
import com.zygh.interactiveplatform.module.entity.Autologos;
import com.zygh.interactiveplatform.module.service.AutologosService;
import com.zygh.interactiveplatform.module.service.AutologosService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lee
 * @since 2021-01-29
 */
@RestController
@RequestMapping("/autologos")
@Api(tags = {SwaggerTagConst.Admin.MANAGER_AUTOLOGOS})
public class AutologosController {
    @Resource
    private AutologosService autologosService;

    @ApiOperation(value = "车标新增", notes = "车标新增")
    @PostMapping("addAutologose")
    @PcLog(logType = "2", module = SwaggerTagConst.Admin.MANAGER_AUTOLOGOS, content = "车标新增")
    public ResponseDTO addAutologose(@RequestBody @Valid Autologos autologos) {
        return autologosService.addAutologos(autologos);
    }
    @ApiOperation(value = "车标修改", notes = "车标修改")
    @PostMapping("updateAutologos")
    @PcLog(logType = "3", module = SwaggerTagConst.Admin.MANAGER_AUTOLOGOS, content = "车标修改")
    public ResponseDTO updateAutologos(@RequestBody @Valid Autologos autologos) {
        return autologosService.updateAutologos(autologos);
    }
    @ApiOperation(value = "车标删除", notes = "车标删除")
    @PostMapping("deleteAutologos")
    @PcLog(logType = "4", module = SwaggerTagConst.Admin.MANAGER_AUTOLOGOS, content = "车标删除")
    public ResponseDTO deleteAutologos(@RequestBody String id) {
        String s = JSONObject.parseObject(id).get("id").toString();
        Integer new_id = Integer.parseInt(s);
        return autologosService.deleteAutologos(new_id);
    }
    @ApiOperation(value = "查询所有车标", notes = "查询所有车标")
    @GetMapping("findAutologosAll")
    @PcLog(logType = "1", module = SwaggerTagConst.Admin.MANAGER_AUTOLOGOS, content = "查询所有车标")
    public ResponseDTO findAutologosAll(Integer current, Integer size) {
        return autologosService.findAutologosAll(current,size);
    }
}
